﻿using System;
using System.Collections.Generic;

namespace WeDonekRpc.Helper.UAParser
{
    internal static class DictionaryExtensions
    {
        public static TValue Find<TKey, TValue> ( this IDictionary<TKey, TValue> dictionary, TKey key )
        {
            if ( dictionary == null )
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            return dictionary.TryGetValue(key, out TValue result) ? result : default;
        }
    }
}
